<%@ page import="com.XiGuaXiaoMe.entity.course" %>

<%@ page import="java.util.List" %>
<%@ page import="com.XiGuaXiaoMe.entity.Users" %>
<%@ page import="com.XiGuaXiaoMe.dao.DaoSc" %>
<%@ page import="com.XiGuaXiaoMe.entity.SC" %><%--

  Created by IntelliJ IDEA.
  User: jl
  Date: 2021/11/10
  Time: 22:19
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    List<course> courses=(List<course>) request.getAttribute("course");
%>
<html lang="zh-CN">
<head>
    <meta charset="utf-8" />

    <link rel="stylesheet" type="text/css" href="http://www.jq22.com/jquery/font-awesome.4.6.0.css">
    <link rel="stylesheet" href="../CSS/css/jquery.paginate.css" />
    <link rel="stylesheet" href="../CSS/css/jquery.yhhDataTable.css" />
    <script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>
    <script type="text/javascript" src="../JS/js/jquery.paginate.js" ></script>
    <script type="text/javascript" src="../JS/js/jquery.yhhDataTable.js" ></script>
    <script type="text/javascript" src="../JS/js/index.js" ></script>
    <link rel="stylesheet" href="../CSS/toPage.css">

    <link rel="stylesheet" href="../font_cqbiizu5og9/iconfont.css">
    <title>自适应导航栏</title>
    <link rel="stylesheet" type="text/css" href="../CSS/导航栏c.css" />
    <link rel="stylesheet" type="text/css" href="../CSS/搜索框样式.css">
    <link rel="stylesheet" type="text/css" href="../CSS/table.css" />
    <link rel="stylesheet" type="text/css" href="../CSS/mainpage.css" />

    <link href="https://fonts.googleapis.com/css?family=Roboto+Condensed:300,300i,400,400i,700i" rel="stylesheet">


</head>
<body style="padding-bottom:10px;">

<iframe class="obj1" src="head.html" frameborder="0" width="1300px" height="90px" scrolling="no"></iframe>
<div class="shell" style=" background-color: #bb3e03;">
    <a href="userinformation.jsp" class="box" style="color: #faedcd;" ><i class="iconfont icon-liebiao"></i><span>个人信息</span></a>
    <a href="课程表1.jsp" class="box" style="color: #faedcd;"><i class="iconfont icon-cangku"></i><span> 查看课表</span></a>
    <a href="/MyWeb/Student/coursefind" class="box"style="color: #faedcd;"><i class="iconfont icon-zhuti_tiaosepan"></i><span>选课</span></a>
    <a href="coursescore.jsp" class="box"style="color: #faedcd;"><i class="iconfont icon-qianbao"></i><span>课程成绩</span></a>
    <a href="日历3.html" class="box" style="color: #faedcd;"><i class="iconfont icon-dunpaibaoxianrenzheng"></i><span>日历</span></a>
    <a href="#" class="box"style="color: #faedcd;"><i class="iconfont icon-dengchu" onclick="shut()"></i><span>退出系统</span></a>
</div>
<section>
    <%
        Users user = null;
        if(session.getAttribute("user")==null){
            response.sendRedirect("/User_Add.jsp");
        }else {
            user = (Users) session.getAttribute("user");
        }

    %>
    <%
        String mess=(String)session.getAttribute("success");

        if(mess!="选课成功"&&mess!="取消选课成功"){
            session.setAttribute("success", "");
        } else{%>

    <script type="text/javascript">

        alert("<%=mess%>");
        session.setAttribute("success", "");
    </script>

    <% }%>
    <%--<div class="navbar">
        <!-- 复选框的id属性值和label元素的for属性值相同的话 那么就可以通过label元素选中复选框 -->
        <input type="checkbox" id="nav" /><label for="nav"></label>
        <ul>
            <li><a href="javascript:;">选课管理</a></li>
            <li><a href="javascript:;">我的选课</a></li>
        </ul>
    </div>--%>
    <div class="a">
        <input type="text" class="b"name="name" id="name" placeholder=" 按照课程名搜索">

        <a onclick="location ='/MyWeb/Student/courseFindServlet4?name='+document.getElementById('name').value;" class="c">
            <img src="../图标/搜索.png" style="width: 30px;">
        </a>
    </div>

    <div class="a">

        <input type="text" class="b" id="teacher" name="teacher" placeholder=" 按照教师名搜索">

        <a onclick="location ='/MyWeb/Student/courseFindServlet3?teacher='+document.getElementById('teacher').value;"  class="c">
            <img src="../图标/搜索.png" style="width: 30px;">
        </a>
    </div>
    <br><br>
    <div class="container">
        <!--分页容器_1-->

        <table id="testtable1" >

            <thead>
            <tr>
                <th>课程名称</th>
                <th>课序号</th>
                <th>代课老师</th>
                <th>上课时间及地点</th>
                <th>课余量</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <%for(course c:courses){ %>

            <tr>
                <td><%=c.getName()%></td>
                <td><%=c.getXuhao()%></td>
                <td><%=c.getTeacher()%></td>
                <td><%=c.getTime()%><%=c.getPlace()%></td>
                <td><%=c.getRongliang()%></td>
                <td><%
                    DaoSc dao=new DaoSc();
                    SC sc=dao.selectone(user.getUserName3(),c.getXuhao());
                    if(sc==null)
                    {%>
                    <input  class="btn" type="button" value="点击选课"
                            onClick="window.location.href=('/MyWeb/Student/serInsertSc?xuhao=<%= c.getXuhao() %>')"

                    <%}else{%>
                    <input  class="btn" type="button" value="点击退选"
                            onClick="window.location.href=('/MyWeb/Student/serDeleteSc?xuhao=<%= c.getXuhao() %>')"

                    <% }%>></td>

            </tr>
            <%}%>

            <tr>
                <td>java</td>
                <td>900</td>
                <td>李老师</td>
                <td>每周五第一节课 4区101</td>
                <td>0</td>
                <td>无法选课</td>
            </tr>

            <tr>
                <td>java</td>
                <td>900</td>
                <td>李老师</td>
                <td>每周五第一节课 4区101</td>
                <td>0</td>
                <td>无法选课</td>
            </tr>
            <tr>
                <td>java</td>
                <td>900</td>
                <td>李老师</td>
                <td>每周五第一节课 4区101</td>
                <td>0</td>
                <td>无法选课</td>
            </tr>
            <tr>
                <td>java</td>
                <td>900</td>
                <td>李老师</td>
                <td>每周五第一节课 4区101</td>
                <td>0</td>
                <td>无法选课</td>
            </tr>
            <tr>
                <td>java</td>
                <td>900</td>
                <td>李老师</td>
                <td>每周五第一节课 4区101</td>
                <td>0</td>
                <td>无法选课</td>
            </tr>
            <tr>
                <td>java</td>
                <td>900</td>
                <td>李老师</td>
                <td>每周五第一节课 4区101</td>
                <td>0</td>
                <td>无法选课</td>
            </tr>
            <tr>
                <td>java</td>
                <td>900</td>
                <td>李老师</td>
                <td>每周五第一节课 4区101</td>
                <td>0</td>
                <td>无法选课</td>
            </tr>

            </tbody >
        </table>


    </div>

</section>

</body>

</html>